package com.seuic.hnjiningposapp.hnapps.ui.view.dialog;

import android.content.Context;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.BasePopupView;
import com.seuic.hnjiningposapp.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * 查询余额成功
 */
public class QuerybalancePp extends BasePopupView {
    @BindView(R.id.card_num_tv)
    TextView cardNumTv;
    @BindView(R.id.card_username)
    TextView cardUsername;
    @BindView(R.id.usable_balance)
    TextView usableBalance;
    @BindView(R.id.query_success_btn)
    Button querySuccessBtn;
    @BindView(R.id.type_tv)
    TextView typeTv;
    Unbinder bind;
    //卡卡号
    String card_num;
    //用户名
    String card_username;
    //余额
    String card_balance;

    String type = "余额"; //如果是电子现金就传入，其他用余额

    Context context;
    OnFinishCallBack mOnFinishCallBack;

    public void setType(String type) {
        this.type = type;
    }

    public String getCard_num() {
        return card_num;
    }

    public void setCard_num(String card_num) {
        this.card_num = card_num;
    }

    public String getCard_username() {
        return card_username;
    }

    public void setCard_username(String card_username) {
        this.card_username = card_username;
    }

    public String getCard_balance() {
        return card_balance;
    }

    public void setCard_balance(String card_balance) {
        this.card_balance = card_balance;
    }

    public QuerybalancePp(@NonNull Context context, OnFinishCallBack onFinishCallBack) {
        super(context);
        this.context = context;
        this.mOnFinishCallBack = onFinishCallBack;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        bind = ButterKnife.bind(this);
        cardNumTv.setText(card_num);
        cardUsername.setText(card_username);
        usableBalance.setText(card_balance);
        typeTv.setText(type);
        querySuccessBtn.setOnClickListener(v -> {
            mOnFinishCallBack.Onfinish();
        });
    }

    @Override
    protected int getPopupLayoutId() {
        return R.layout.query_success_layout;
    }

    @Override
    protected void onDismiss() {
        super.onDismiss();
        //注解解绑
        if (bind != null && bind != Unbinder.EMPTY) {
            bind.unbind();
        }
        this.bind = null;
    }

    public interface OnFinishCallBack {
        void Onfinish();
    }

}
